//========================================================================================
//  
//  $File: $
//  
//  Owner: Toan Nguyen
//  
//  $Author: $
//  
//  $DateTime: $
//  
//  $Revision: $
//  
//  $Change: $
//  
//  Copyright 1997-2008 Adobe Systems Incorporated. All rights reserved.
//  
//  NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance 
//  with the terms of the Adobe license agreement accompanying it.  If you have received
//  this file from a source other than Adobe, then your use, modification, or 
//  distribution of it requires the prior written permission of Adobe.
//  
//========================================================================================
#include "VCPlugInHeaders.h"

// Interface includes

// Other API includes
#include "K2Vector.tpp"

// Project includes
#include "AMPIssuesDataNode.h"
//#include "PnlTrvUtils.h"

#include <iostream>
using namespace std;

/**
	@ingroup paneltreeview
*/

/* Constructor
*/
AMPIssuesDataNode::AMPIssuesDataNode() : fParent(nil)
{
}


/* Destructor
*/
AMPIssuesDataNode::~AMPIssuesDataNode()
{
}


/********************************************************************************************************************
 *****Function: AMPIssuesDataNode
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
AMPIssuesDataNode::AMPIssuesDataNode(const AMPIssuesDataNode& rhs) : fParent(nil)
{
	deepcopy(rhs);
}

/********************************************************************************************************************
 *****Function: perator=
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
AMPIssuesDataNode& AMPIssuesDataNode::operator=(const AMPIssuesDataNode& rhs)
{
	deepcopy(rhs);
	return *this;
}


/********************************************************************************************************************
 *****Function: operator==
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
bool AMPIssuesDataNode::operator==(const AMPIssuesDataNode& rhs) const
{
	return		this->fParent == rhs.fParent && 
				this->fPathData == rhs.fPathData &&
				this->fChildren == rhs.fChildren;
}


/********************************************************************************************************************
 *****Function: deepcopy
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::deepcopy(const AMPIssuesDataNode& rhs)
{
	this->fChildren.clear();
	this->fChildren.assign( rhs.fChildren.begin(), rhs.fChildren.end());
	this->fParent = rhs.fParent;
	this->fPathData = rhs.fPathData;
	
	// added by Vu Tiet
	//cout << "AMPIssuesDataNode::deepcopy " << rhs.fNodeName.GrabCString() << endl;
	this ->fNodeName = rhs.fNodeName;
	this->fNodeImgPath = rhs.fNodeImgPath;
	this->nodeType = rhs.nodeType;
	this->IsNodeSelected = rhs.IsNodeSelected;
	this->nodeNumber = rhs.nodeNumber;
	this->fstatus = rhs.fstatus;	//status
	this->fediting_status = rhs.fediting_status;
}


/********************************************************************************************************************
 *****Function: GetNthChild
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
const AMPIssuesDataNode& AMPIssuesDataNode::GetNthChild(
	int32 indexInParent) const
{
	return this->fChildren.at(indexInParent);
}


/********************************************************************************************************************
 *****Function: AddChild
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::AddChild(const AMPIssuesDataNode& o)
{
	this->fChildren.push_back(o);
}


/********************************************************************************************************************
 *****Function: RemoveChild
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::RemoveChild(const AMPIssuesDataNode& o)
{
	K2Vector<AMPIssuesDataNode>::iterator result = std::find(fChildren.begin(), 
													fChildren.end(), o);

	if(result != fChildren.end())
	{
		fChildren.erase(result);
	}
}


/********************************************************************************************************************
 *****Function: GetParent
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
AMPIssuesDataNode* AMPIssuesDataNode::GetParent() const
{
	return this->fParent;
}


/********************************************************************************************************************
 *****Function: SetParent
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::SetParent(const AMPIssuesDataNode* p)
{
	this->fParent = const_cast<AMPIssuesDataNode* >(p);
}

/********************************************************************************************************************
 *****Function: ChildCount
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int32 AMPIssuesDataNode::ChildCount() const
{
	return this->fChildren.size();
}


/********************************************************************************************************************
 *****Function: SetData
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::SetData(const PMString& data)
{
	this->fPathData = data;
}


/********************************************************************************************************************
 *****Function: GetData
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
PMString AMPIssuesDataNode::GetData() const
{
	return this->fPathData;
}


/********************************************************************************************************************
 *****Function: getType
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int AMPIssuesDataNode::getType() const {
	return nodeType;
}

/********************************************************************************************************************
 *****Function: setType
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setType(const int type) {
	nodeType = type;
}


/********************************************************************************************************************
 *****Function: GetNodeName
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
PMString AMPIssuesDataNode::GetNodeName() const {
	//cout << "AMPIssuesDataNode::GetNodeName fNodeName: " << this->fNodeName.GrabCString() << endl;
	return this->fNodeName;
}

/********************************************************************************************************************
 *****Function: SetNodeName
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/	
void AMPIssuesDataNode::SetNodeName(const PMString& nodeName) {
	this->fNodeName = nodeName;
}

/********************************************************************************************************************
 *****Function: GetNodeID
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
PMString AMPIssuesDataNode::GetNodeID() const {
	return this->fNodeID;
}


/********************************************************************************************************************
 *****Function: setNodeID
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setNodeID(const PMString& nodeID) {
	this->fNodeID = nodeID;
}


/********************************************************************************************************************
 *****Function: GetNodeImgPath
 *****Creator:  Vu Tiet
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
PMString AMPIssuesDataNode::GetNodeImgPath() const {
	return this->fNodeImgPath;
}


/********************************************************************************************************************
 *****Function: setNodeImgPath
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setNodeImgPath(const PMString& nodeImgPath) {
	this->fNodeImgPath = nodeImgPath;
}

/********************************************************************************************************************
 *****Function: deleteNode
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::deleteNode()
{
	this->fChildren.clear();
	this->fParent = nil;
	this->fPathData = nil;
	
	this->fNodeName = nil;
	this->fNodeImgPath = nil;
	this->nodeType = nil;
	this->IsNodeSelected = FALSE;
	this->nodeNumber = nil;
	this->fstatus = 1;
	this->fediting_status = 208;
}

/********************************************************************************************************************
 *****Function: getNodeSelect
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int AMPIssuesDataNode::getNodeSelect() const {		// new add 28-08-2012
	return this->IsNodeSelected;
}

/********************************************************************************************************************
 *****Function: setNodeSelect
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setNodeSelect(const int type) {		// new add 28-08-2012
	//cout << "++++++++++++++++++++++++++++++++++++" << endl;
	//cout << "path = " << fPathData.GrabCString() << endl;
	//cout << "parentPath2: " << fPathData.GrabCString() << endl;
	//cout << "parentName2: " << fNodeName.GrabCString() << endl;
	//cout << "parentImgPath2: " << fNodeImgPath.GrabCString() << endl;
	//cout << "parentDataType2: " << nodeType << endl;
	//cout << "parentDataCheck2: " << type << endl;
	//cout << "++++++++++++++++++++++++++++++++++++" << endl;
	this->IsNodeSelected = type;
}

/********************************************************************************************************************
 *****Function: GetNodeNumber
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int AMPIssuesDataNode::GetNodeNumber() const {
	return this->nodeNumber;
}

/********************************************************************************************************************
 *****Function: SetNodeNumber
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::SetNodeNumber(const int newNumber) {
	this->nodeNumber = newNumber;
}

/********************************************************************************************************************
 *****Function: getNodeStatus
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int AMPIssuesDataNode::getNodeStatus() const {
	return this->fstatus;
}

/********************************************************************************************************************
 *****Function: setNodeStatus
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setNodeStatus(const int _status) {
	this->fstatus = _status;
}

/********************************************************************************************************************
 *****Function: getNodeEditing
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
int AMPIssuesDataNode::getNodeEditing() const {		// new add 28-08-2012
	return this->fediting_status;
}

/********************************************************************************************************************
 *****Function: setNodeEditing
 *****Creator:  Toan Nguyen
 *****IN: 
 *****out: 
 *****Objective: 
 ********************************************************************************************************************/
void AMPIssuesDataNode::setNodeEditing(const int type) {		// new add 28-08-2012
	this->fediting_status = type;
}

//	end, File:	AMPIssuesDataNode.cpp
